package com.zrrd.learn.chapter09.collection;

import java.util.LinkedList;
import java.util.Queue;

/**
 * 学习队列
 *
 * @author wrn
 * @version 1.0
 * @date 2023/8/15 10:10
 */

public class LearnQueue {

    public static void main(String[] args) {
        //约瑟夫环

        Queue<Integer> nos = new LinkedList<>();

        for (int i = 0; i < 10; i++) {
            nos.add(i+1);
        }
        System.out.println(nos);
        System.out.println("约瑟夫环");

        while (nos.size() >1 ) {
            nos.add(nos.poll());
            nos.add(nos.poll());
            nos.poll();
            System.out.println("最终结果" + nos);

        }
    }

}
